﻿using MediatR;
using SystemLYH.API.Application.Command.QualityCommand;
using SystemLYH.Domain;
using SystemLYH.Infrstructre.Impl;
using SystemLYH.Infrstructre.Interface;

namespace SystemLYH.API.Application.Handlers.QualityHandlers
{
    public class QualityCreateHandlers : IRequestHandler<QualityCreateCommand, int>
    {
        protected readonly IQualityRepository _qualityRepository;
        /// <summary>
        /// 库位构造函数
        /// </summary>
        /// <param name="qualityRepository"></param>
        public QualityCreateHandlers(IQualityRepository qualityRepository)
        {
            _qualityRepository = qualityRepository;
        }
        public async Task<int> Handle(QualityCreateCommand request, CancellationToken cancellationToken)
        {
            return await _qualityRepository.CreaseAsync(new Qualityduring()
            {
                QualityNumber = request.QualityNumber,
                QualityName = request.QualityName,
                SupplierID = request.SupplierID,
                finishedProductNumber=request.finishedProductNumber,
                finishedProductName=request.finishedProductName,
                finishedProductModel=request.finishedProductModel,
                BomNumbering = request.BomNumbering,
                finishedSize = request.finishedSize,
                finishedBatch =request.finishedBatch,
                productionlineNumber=request.productionlineNumber,
                productionlineName=request.productionlineName,
                CraftManageNumber = request.CraftManageNumber,
                CraftManageName = request.CraftManageName,
                ProcessNumber =request.ProcessNumber,
                ProcessName =request.ProcessName,
                Qualityquantity = request.Qualityquantity,
                Qualified =request.Qualified,
                UnQualified =request.UnQualified,
                QualityResults = request.QualityResults,
                AddName = "李子坤",
                AddTime = DateTime.Now.ToUniversalTime(),
            });
        }
    }
}
